<template>
	<el-container>
		<!-- <el-header style="height: auto;">
			<sc-select-filter :data="filterData" :label-width="80" @on-change="filterChange"></sc-select-filter>
		</el-header> -->
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="apiObj" row-key="runId" stripe remoteSort remoteFilter>
				<el-table-column label="#" type="index" width="50"></el-table-column>
				<el-table-column label="流水号" prop="id" width="150"></el-table-column>
				<el-table-column label="活动名称" prop="eventName" width="150"></el-table-column>
				<el-table-column label="活动说明" prop="description" width="150"></el-table-column>

<!--				<el-table-column label="部门" prop="deptName" width="150"></el-table-column>-->
				<el-table-column label="申请人姓名" prop="userName" width="200" ></el-table-column>
				<el-table-column label="申请人部门" prop="deptName" width="200"></el-table-column>
				<el-table-column label="参与人数" prop="participantCount" width="150"></el-table-column>
				<el-table-column label="审批人" prop="approverName" width="150"></el-table-column>
				<el-table-column label="审批人部门" prop="approverDeptName" width="150"></el-table-column>
				<el-table-column label="状态" prop="status">
					<template #default="scope">
						<span v-if="scope.row.status === '0'">审核中</span>
						<span v-else-if="scope.row.status === '1'">通过</span>
						<span v-else-if="scope.row.status === '2'">驳回</span>
						<span v-else-if="scope.row.status === '3'">初始化</span>
						<span v-else-if="scope.row.status === '99'">撤销</span>
					</template>
				</el-table-column>
				<el-table-column label="开始时间" prop="startDate" width="150" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="结束时间" prop="endDate" width="150" :show-overflow-tooltip="true"></el-table-column>
				<el-table-column label="预算总金额" prop="totalBudget" width="150" :show-overflow-tooltip="true"></el-table-column>

				<el-table-column label="操作" fixed="right" align="right" width="100">
					<template #default="scope">
						<el-button-group>
							<el-button text type="primary" size="small" @click="readBpmDetails(scope.row,scope.$index)">查看预算明细</el-button>
						</el-button-group>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
		<el-dialog v-model="dialogVisible" title="费用明细" width="60%">
			<el-table :data="oaFinanceDetails">
				<el-table-column label="id" prop="id" ></el-table-column>
				<el-table-column label="内容" prop="content" ></el-table-column>
				<el-table-column label="金额" prop="amount" ></el-table-column>
			</el-table>
			<template #footer>
				<el-button @click="dialogVisible = false">关闭</el-button>
			</template>
		</el-dialog>

	</el-container>
</template>

<script>
import scSelectFilter from '@/components/scSelectFilter'
export default {
	name: 'My Attend Record',
	components: {
		scSelectFilter,
	},
	data() {
		return {
			dialog: {
				save: false,
				detailsSave:false
			},
			apiObj: null,
			search: {
				date:''
			},
			dialogVisible: false, // 控制弹窗显示
			oaFinanceDetails: [], // 存储费用明细数据
			addFormVisible: false, // 控制新增表单弹窗显示
			formData: {
				oaFinance:{},
				oaFinanceDetailsList:[],
				oaFlows:[],
			}
		}
	},
	mounted() {
		this.initApiObj();
	},
	methods: {
		// 初始化apiObj
		initApiObj() {
			const userInfo = this.$TOOL.data.get("USER_INFO");
			this.apiObj = {
				get: async (params) => {
					// 合并固定参数（userInfo.id）和动态参数（this.search）
					const mergedParams = {
						option1: userInfo.id,
						...this.search,
						...params // 允许外部传入的params覆盖默认值
					};
					return await this.$API.office.personalFinance.getByPurchaser.get(mergedParams);
				}
			};
		},
		filterChange(data){
			this.search.date = data.date;
			this.$refs.table.upData(this.search); // 触发表格重新加载
		},
		readBpmDetails(row,index){
			this.oaFinanceDetails = row.oaFinanceDetails;
			console.log(this.oaFinanceDetails);
			this.dialogVisible = true; // 显示弹窗
		},
	}
}
</script>

<style>
</style>
